package com.iss.demo.service;

import com.iss.demo.dao.UserDao;
import com.iss.demo.entity.User;
import com.iss.demo.entity.xtCourse;
import com.iss.demo.model.UserWithRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserDao dao;

    public UserWithRole login(User user){
        return dao.login(user);
    }

    public boolean checkUserNameExist(String u_name){
        User user = dao.checkUserNameExist(u_name);
        if(user == null){
            return false;
        }
        return  true;
    }

    public Integer insert(User user){
        return dao.insert(user);
    }

    public List<User> selectAll(){
        List<User> list = new ArrayList<>();
        list = dao.selectAll();
        return list;
    }
    public Integer update(User user){
        return dao.update(user);

    }
    public Integer deleteOne(Integer u_id){
        return dao.deleteOne(u_id);
    }

    public User selectById(Integer id){return dao.selectByid(id);}
}
